package com.ruoyi.fee.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.fee.domain.WGoodsTransferFeeRule;
import com.ruoyi.fee.service.IWGoodsTransferFeeRuleService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 货转费Controller
 * 
 * @author wzy
 * @date 2024-08-30 14:11:06
 */
@RestController
@RequestMapping("/fees/goodstransfer")
public class WGoodsTransferFeeRuleController extends BaseController
{
    @Autowired
    private IWGoodsTransferFeeRuleService wGoodsTransferFeeRuleService;

    /**
     * 查询货转费列表
     */
    @PreAuthorize("@ss.hasPermi('fees:goodstransfer:list')")
    @GetMapping("/list")
    public TableDataInfo list(WGoodsTransferFeeRule wGoodsTransferFeeRule)
    {
        startPage();
        List<WGoodsTransferFeeRule> list = wGoodsTransferFeeRuleService.selectWGoodsTransferFeeRuleList(wGoodsTransferFeeRule);
        return getDataTable(list);
    }

    /**
     * 导出货转费列表
     */
    @PreAuthorize("@ss.hasPermi('fees:goodstransfer:export')")
    @Log(title = "货转费", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WGoodsTransferFeeRule wGoodsTransferFeeRule)
    {
        List<WGoodsTransferFeeRule> list = wGoodsTransferFeeRuleService.selectWGoodsTransferFeeRuleList(wGoodsTransferFeeRule);
        ExcelUtil<WGoodsTransferFeeRule> util = new ExcelUtil<WGoodsTransferFeeRule>(WGoodsTransferFeeRule.class);
        util.exportExcel(response, list, "货转费数据");
    }

    /**
     * 获取货转费详细信息
     */
    @PreAuthorize("@ss.hasPermi('fees:goodstransfer:query')")
    @GetMapping(value = "/{goodsTransferFeeId}")
    public AjaxResult getInfo(@PathVariable("goodsTransferFeeId") Long goodsTransferFeeId)
    {
        return success(wGoodsTransferFeeRuleService.selectWGoodsTransferFeeRuleByGoodsTransferFeeId(goodsTransferFeeId));
    }

    /**
     * 新增货转费
     */
    @PreAuthorize("@ss.hasPermi('fees:goodstransfer:add')")
    @Log(title = "货转费", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WGoodsTransferFeeRule wGoodsTransferFeeRule)
    {
        wGoodsTransferFeeRule.setCreateBy(getNickName());
        return toAjax(wGoodsTransferFeeRuleService.insertWGoodsTransferFeeRule(wGoodsTransferFeeRule));
    }

    /**
     * 修改货转费
     */
    @PreAuthorize("@ss.hasPermi('fees:goodstransfer:edit')")
    @Log(title = "货转费", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WGoodsTransferFeeRule wGoodsTransferFeeRule)
    {
        wGoodsTransferFeeRule.setUpdateBy(getNickName());
        return toAjax(wGoodsTransferFeeRuleService.updateWGoodsTransferFeeRule(wGoodsTransferFeeRule));
    }

    /**
     * 删除货转费
     */
    @PreAuthorize("@ss.hasPermi('fees:goodstransfer:remove')")
    @Log(title = "货转费", businessType = BusinessType.DELETE)
	@DeleteMapping("/{goodsTransferFeeIds}")
    public AjaxResult remove(@PathVariable Long[] goodsTransferFeeIds)
    {
        return toAjax(wGoodsTransferFeeRuleService.deleteWGoodsTransferFeeRuleByGoodsTransferFeeIds(goodsTransferFeeIds));
    }
}
